﻿/*
 *   FoxConvert.cs
 *   Copyright (c) 2011 - BitFox Software and Ricardo Federico Villafañes
 *   Contact: federvillaf@hotmail.com
 *   
 *   Licensing: This product is covered by Microsoft Reciprocal License (MS-RL)
 *              see https://bitfoxeval.codeplex.com/license
*/

using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BitFox
{
    /// <summary>
    /// Helper class for conversions that use globalization
    /// </summary>
    /// <remarks>
    /// TODO: This class shouldn't be static and, during it's instantiation, it must receive a Context that 
    /// give precisions about how to handle global things.
    /// </remarks>
    static class FoxConvert
    {
        public static decimal ToDecimal(object obj)
        {
            return Convert.ToDecimal(obj, CultureInfo.InvariantCulture);
        }

        public static short ToInt16(object obj)
        {
            return Convert.ToInt16(obj, CultureInfo.InvariantCulture);
        }

        public static int ToInt32(object obj)
        {
            return Convert.ToInt32(obj, CultureInfo.InvariantCulture);
        }

        public static long ToInt64(object obj)
        {
            return Convert.ToInt64(obj, CultureInfo.InvariantCulture);
        }

        public static object ChangeType(object obj, Type targetType)
        {
            return Convert.ChangeType(obj, targetType, CultureInfo.InvariantCulture);
        }
    }
}
